package io.xccit.race.service.impl;

import java.util.List;
import io.xccit.common.utils.DateUtils;
import io.xccit.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import io.xccit.race.mapper.RaceCompetitionWinMapper;
import io.xccit.race.domain.RaceCompetitionWin;
import io.xccit.race.service.IRaceCompetitionWinService;

/**
 * 竞赛获奖管理Service业务层处理
 * 
 * @author ywx
 * @date 2025-10-13
 */
@Service
public class RaceCompetitionWinServiceImpl implements IRaceCompetitionWinService {
    @Autowired
    private RaceCompetitionWinMapper raceCompetitionWinMapper;

    /**
     * 查询竞赛获奖管理
     * 
     * @param id 竞赛获奖管理主键
     * @return 竞赛获奖管理
     */
    @Override
    public RaceCompetitionWin selectRaceCompetitionWinById(Long id) {
        return raceCompetitionWinMapper.selectRaceCompetitionWinById(id);
    }

    /**
     * 查询竞赛获奖管理列表
     * 
     * @param raceCompetitionWin 竞赛获奖管理
     * @return 竞赛获奖管理
     */
    @Override
    public List<RaceCompetitionWin> selectRaceCompetitionWinList(RaceCompetitionWin raceCompetitionWin) {
        return raceCompetitionWinMapper.selectRaceCompetitionWinList(raceCompetitionWin);
    }

    /**
     * 新增竞赛获奖管理
     * 
     * @param raceCompetitionWin 竞赛获奖管理
     * @return 结果
     */
    @Override
    public int insertRaceCompetitionWin(RaceCompetitionWin raceCompetitionWin) {
        if (raceCompetitionWin.getDelFlag() == null) {
            raceCompetitionWin.setDelFlag("0");
        }
        if (raceCompetitionWin.getAwardTime() == null) {
            raceCompetitionWin.setAwardTime(DateUtils.getNowDate());
        }
        raceCompetitionWin.setCreateBy(SecurityUtils.getUsername());
        return raceCompetitionWinMapper.insertRaceCompetitionWin(raceCompetitionWin);
    }

    /**
     * 修改竞赛获奖管理
     * 
     * @param raceCompetitionWin 竞赛获奖管理
     * @return 结果
     */
    @Override
    public int updateRaceCompetitionWin(RaceCompetitionWin raceCompetitionWin) {
        raceCompetitionWin.setUpdateBy(SecurityUtils.getUsername());
        return raceCompetitionWinMapper.updateRaceCompetitionWin(raceCompetitionWin);
    }

    /**
     * 批量删除竞赛获奖管理
     * 
     * @param ids 需要删除的竞赛获奖管理主键
     * @return 结果
     */
    @Override
    public int deleteRaceCompetitionWinByIds(Long[] ids) {
        return raceCompetitionWinMapper.deleteRaceCompetitionWinByIds(ids);
    }

    /**
     * 删除竞赛获奖管理信息
     * 
     * @param id 竞赛获奖管理主键
     * @return 结果
     */
    @Override
    public int deleteRaceCompetitionWinById(Long id) {
        return raceCompetitionWinMapper.deleteRaceCompetitionWinById(id);
    }
}
